package chapter4.inject_and_applicationcontext;

import org.springframework.context.support.GenericXmlApplicationContext;

public class TagetSimple {
	private String val;

	public String getVal() {
		return val;
	}

	public void setVal(String val) {
		this.val = val;
	}

	public static void main(String[] args) {
		GenericXmlApplicationContext parent = new GenericXmlApplicationContext();
		parent.load("classpath:chapter4/inject_and_applicationcontext/parent.xml");
		parent.refresh();

		GenericXmlApplicationContext child = new GenericXmlApplicationContext();
		child.load("classpath:chapter4/inject_and_applicationcontext/app-context-xml.xml");
		child.setParent(parent);
		child.refresh();

		TagetSimple taget1 = (TagetSimple) child.getBean("target1");
		TagetSimple taget2 = (TagetSimple) child.getBean("target2");
		TagetSimple taget3 = (TagetSimple) child.getBean("target3");

		System.out.println(taget1.val);
		System.out.println(taget2.val);
		System.out.println(taget3.val);
	}
}
